
const f2 = function() {

}


// 语法糖
// const NewCar = class Car {
const NewCar = class {
  constructor(uname, color) {
    this.uname = uname
    this.color = color
    // this.active = 'stop'
  }
  // active = 'stop'

  get count() {
    return 100
  }

  set count(num) {
    console.log(num)
    return num
  }

  run() {
    console.log(this.uname + 'running !!!')
  }

  static mySay() {
    console.log('hi')
  }
}

// console.log(NewCar.mySay())
// console.log(typeof Car)
// console.log(Car.prototype.constructor === Car)
// let car1 = new Car('丰田', '#fff')
// let car2 = new Car('本田', '#000')
// console.log(car1.__proto__)

let car1 = new NewCar('丰田', '#fff')
let car2 = new NewCar('本田', '#000')
console.log(car1)
// console.log(car1.mySay)
console.log(car2)
// console.log(car1.count)
// car1.count = 222
// console.log(car1)


// class 子类 extends 父类 {
class Bmw extends NewCar {
  constructor(uname, color, area) {
    super(uname, color);
  }
}

let b1 = new Bmw('宝马', '灰色', '华晨')
console.log(b1)
console.log(b1.run())

console.log(Bmw.mySay())
// console.log(b1.mySay())

// console.log(b1 instanceof Bmw) // true
// console.log(b1 instanceof NewCar) // true

// console.log(car1 instanceof Bmw) // false
// console.log(car1 instanceof NewCar) // true


// console.log(Bmw)
// console.log(Bmw.prototype)



/*
function Car(uname, color) {
  this.uname = uname
  this.color = color
}
// console.log(Car.prototype.constructor)
Car.prototype.run = function () {
  console.log(this.uname + 'running !!!')
}
// console.log(Car.prototype)
let car1 = new Car('丰田', '#fff')
let car2 = new Car('本田', '#000')
car1.run()
car2.run()

// console.log(car1)
// console.log(car2)
*/

